feat(hook): add Qoder CLI agent support#1721
Conversation
Add `rtk init --agent qoder` for Qoder CLI integration. Qoder CLI uses the same PreToolUse JSON protocol as Claude Code (tool_input.command + updatedInput), so `rtk hook qoder` reuses the existing process_claude_payload logic for transparent command rewriting — no denial, no retry, zero token overhead. Both project-scoped (`rtk init --agent qoder` → .qoder/) and global (`rtk init -g --agent qoder` → ~/.qoder/) installations are supported. The init function detects existing workaround hooks (e.g. shell scripts from issue rtk-ai#1327) and upgrades them automatically to the native binary. Changes: - src/main.rs: Add Qoder to AgentTarget and HookCommands enums - src/hooks/constants.rs: Add QODER_DIR = ".qoder" - src/hooks/hook_cmd.rs: Add run_qoder() handler + 4 unit tests - src/hooks/init.rs: Add run_qoder_mode(), patch_qoder_settings(), upgrade detection, idempotent settings.json merging, + 4 unit tests - hooks/qoder/: README.md + rtk-awareness.md - hooks/README.md: Add Qoder to supported agents table + JSON format - src/hooks/README.md: Add Qoder to permission model table - README.md: Add Qoder CLI to quick start and supported tools table Closes rtk-ai#1327
SummaryAdd Qoder CLI uses the same Changes
Usage# Project-scoped: writes to .qoder/ (RTK.md + AGENTS.md @RTK.md + settings.json hook)
rtk init --agent qoder
# Global: writes to ~/.qoder/ (RTK.md + settings.json hook)
rtk init -g --agent qoderHow it worksQoder CLI supports Compound commands (with Compared to the workaround shell scriptBefore this PR, Qoder users on #1327 used a custom shell script
The native integration is strictly better — transparent rewrite eliminates Recent enhancements
Verification# Build
cargo build --release
# Test hook handler
echo '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | ./target/release/rtk hook qoder
# → {"hookSpecificOutput":{"updatedInput":{"command":"rtk git status"}}}
# Test project-scoped init
rtk init --agent qoder
# → Creates RTK.md, patches AGENTS.md, writes .qoder/settings.json
# Test global init
rtk init -g --agent qoder
# → Creates ~/.qoder/RTK.md, patches ~/.qoder/settings.json
# Test upgrade from shell script
# (if you previously used the workaround from #1327)
rtk init -g --agent qoder -v
# → "Upgraded Qoder hook from `~/.qoder/hooks/rtk-qoder-hook.sh` to `rtk hook qoder`"
# Run tests
cargo test --bin rtk -- qoder # 8 tests
cargo test --bin rtk # 1695 tests (all pass) |
Summary
Add
rtk init --agent qoderfor Qoder CLI integration. Closes #1327.PreToolUseJSON protocol as Claude Code, sortk hook qoderreuses the existingprocess_claude_payloadlogic for transparent command rewritingrtk init --agent qoder→.qoder/) and global (rtk init -g --agent qoder→~/.qoder/) installationrtk initmultiple times never duplicates hook entries or overwrites existing settingsTest plan
cargo fmt --all --check && cargo clippy --all-targets && cargo testrtk <command>output inspectedrtk init --agent qoder— creates RTK.md, patches AGENTS.md, writes.qoder/settings.jsonrtk init -g --agent qoder— creates~/.qoder/RTK.md, patches~/.qoder/settings.jsonecho '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | rtk hook qoder— returnsupdatedInputwithrtk git statusrtk initreplaces~/.qoder/hooks/rtk-qoder-hook.shwithrtk hook qoderhook_cmd.rs: rewrite Bash, pass-through non-Bash, pass-through already-rtk, pass-through echoinit.rs: fresh install, shell script upgrade, idempotency, existing settings preservationRead) pass through silently&&,||,|) handled byrewrite_compound()